﻿namespace EyeOpen.Web.Mvc
{
	using System.Web.Mvc;

	public abstract class RemoteResolverAttribute : RemoteAttribute
	{
		protected RemoteResolverAttribute()
		{
			RouteData["controller"] = GetControllerName();
			RouteData["action"] = "Validate";
		}

		protected void RegisterProperty<T>(string propertyName, T value)
		{
			RouteData[propertyName] = value;
		}

		private string GetControllerName()
		{
			var typeName = GetType().Name;

			typeName = typeName.Replace("RemoteAttribute", null);
			
			return string.Format("{0}", typeName);
		}
	}
}